package com.ddwl.gate.mq.receive;

import com.ddwl.common.config.DingTalkNotify;
import com.ddwl.common.constant.RabbitMqConstants;
import com.ddwl.gate.service.MobileRechargeRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author hemiaojun
 * @Date 2020/9/27 11:03
 */
@Slf4j
@Component
public class PayTimeOutReceive {

    @Resource
    private MobileRechargeRecordService mobileRechargeRecordService;
    @Resource
    private DingTalkNotify dingTalkNotify;

    /**
     * 接收手机充值订单超时关闭消息
     * @param id
     */
    @RabbitListener(queues = RabbitMqConstants.MOBILE_RECHARGE_ORDER_TIMEOUT_REDIRECT_QUEUE)
    public void payTimeOutProcess(String id){
        log.info("mobile recharge orderId: {}", id);
        try {
            mobileRechargeRecordService.payTimeOutProcess(id);
        } catch (Exception e) {
            log.error("PayTimeOutReceive.payTimeOutProcess error",e);
            dingTalkNotify.exceptionNotify(e);
        }
    }

}
